<template>
  <div>
    <!-- 商品分类导航 -->
    <!-- 三级联动的全局组件, 三级联动已经注册为全局组件，因此不需要引入-->
    <TypeNav />

    <!--列表-->
    <ListContainer />

    <!--今日推荐-->
    <TodayRecommend />

    <!-- 商品排行 -->
    <Rank />

    <!-- 猜你喜欢 -->
    <Like />

    <!--楼层-->
    <Floor v-for="(floor, index) in floorList" :key="floor.id" :list="floor" />

    <!--商标-->
    <Brand />
  </div>
</template>

<script>
//引入其余的组件
import ListContainer from '@/pages/Home/ListContainer'
import TodayRecommend from '@/pages/Home/TodayRecommend'
import Rank from '@/pages/Home/Rank'
import Like from '@/pages/Home/Like'
import Floor from '@/pages/Home/Floor'
import Brand from '@/pages/Home/Brand'
import { mapState } from 'vuex'

export default {
  name: 'Home',
  components: {
    ListContainer,
    TodayRecommend,
    Rank,
    Like,
    Floor,
    Brand,
  },
  mounted() {
    //派发action获取floor组件的数据
    this.$store.dispatch("getFloorList")
    //
    // this.getUserInfo()

  },
  computed: {
    ...mapState({
      floorList: state => state.home.floorList
    })
  },
  methods: {
    // async getUserInfo() {
    //   try {
    //     await this.$store.dispatch('getUserInfo')
    //   } catch (error) {
    //     console.log(error.message)
    //   }
    // },
  },

}
</script>